<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title>Document</title>
		<link rel="stylesheet" href="../layui/css/layui.css">
		<link rel="stylesheet" type="text/css" href="../css/register.css">
	</head>
	<style type="text/css">
	.getcode{
		font-size: 12px;
		color: #58d5f4;
		border: none;
		border-radius: 5px;
		padding:none;
		position: absolute;
		right: 0;
		bottom: 10px;
	}
	.getcode input{
		font-size: 12px;
		color: #58d5f4;
		border: 1px solid #58d5f4;
		border-radius: 5px;
		background: #fff;
		padding: 3px 5px;
	}
	.clearfix:after{
		content: '';
		display: block;
		clear: both;
	}
	.head_wrap span,.head_wrap div{
		float: left;
	}
	.head{
		width: 60px;
		height: 60px;
		border: 1px solid #ccc;
		border-radius: 100%;
		position: relative; 
	}
	.head img{
		width: 100%;
		height: 100%;
		opacity: 0;
		border-radius: 100%;
		left: 0;
		top: 0;
	}
	.head input{
		position: absolute;
		width: 100%;
		height: 100%;
		position: absolute;
		left: 0;
		top: 0;
		opacity: 0;
		z-index: 9999;
	}
	</style>
	<body>
		<header>
			<a href="javascript:history.back(-1)" class="back"><img src="../img/back.png" height="18px"></a>
			<div class="center title">注册</div>
		</header>
		<form action="post" enctype="multipart/form-data">	
		<div class="register">
			<div class="flex" style="margin-top:25px; ">
				<input type="text" name="phone" placeholder="请输入手机号">
				<div class="getcode"><input class="getcode_btn" type="button" name="" class="yanzhengbtn" value="获取验证码"></div>
			</div>
			<input type="text" name="code" placeholder="请输入验证码">
			<input type="password" name="password" placeholder="请输入密码">
			<div class="confirm center">注册</div>
			<p class="agreement center">登录即表示你已阅读并同意<a href="protocol.html">注册协议</a></p>
		</div>
		</form>
		<!-- <div class="hqsession">session</div> -->
	</body>
</html>

<script src="../js/jquery-3.3.1.js"></script>
<script src="../layui/layui.all.js"></script>
<script>
	
	 var va_code = true;
	// 发送验证码
	$('.getcode_btn').click(function () {
		var phone=$('input[name="phone"]').val();
		var smg_code = 60;
        var code_class = $(this);
		if(phone.length<11||phone==''){
			layer.msg('请输入手机号码');
			return false;
		}
		if(va_code){
			$.post('/meiyou/sendMsg',{phone:phone,msgtype:2},function (data) {
			if (data.code==100){
				layer.msg(data.msg);
				 var time = setInterval(function(){
                            smg_code--;
                            code_class.val("重新发送("+smg_code+")");
                           
                            if(smg_code==0){
                                clearInterval(time);
                                code_class.val("重新发送");
                           
                                va_code = true;
                            }
                        },1000)
			}else{
				layer.msg(data.msg);
			}
		});
		}
	});
	
	//注册
$('.confirm').click(function () {
	
	var phone=$('input[name="phone"]').val();
	var code=$('input[name="code"]').val();
	var password=$('input[name="password"]').val();
	
	if(phone==''||phone.length<11){
			layer.msg('请输入正确的手机号码');
			return false;
	}else if(code==''){
		layer.msg('请输入验证码');
		return false;
	}else if(password==''){
		layer.msg('请输入密码');
		return false;
	}
    $.post('/meiyou/regist',{phone:phone,code:code,password:password},function(data){
		if(data.code==100){
          layer.msg(data.msg);
          // localStorage.setItem('uccon',phone);
          window.location.href='per-data.html'
         }else{
          layer.msg(data.msg);
         }
    })
});
</script>
<!-- <script type="text/javascript">
	/*验证码倒计时*/
var countdown=60;
function sendemail(){
    var obj = $(".yanzhengbtn");
    settime(obj);

}
function settime(obj) { //发送验证码倒计时
    if (countdown == 0) {
        obj.attr('disabled',false);
        /*obj.removeattr("disabled");*/
        obj.val("获取验证码");
        countdown = 60;
        return;
    } else {
        obj.attr('disabled',true);
        obj.val("重新发送(" + countdown + ")");
        countdown--;
    }
    setTimeout(function() {
            settime(obj) }
        ,1000)
}

</script> -->